package cn.edu.hbpu.controller.v1;

import cn.edu.hbpu.common.R;
import cn.edu.hbpu.entity.Goods;
import cn.edu.hbpu.service.GoodsService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author lcy
 * @date 2022/8/23 13:13
 * @description
 */
@RestController
@RequestMapping("/goods")
public class GoodsController {

    @Autowired
    private GoodsService goodsService;

    /**
     * 分页查询商品信息
     *
     * @param page
     * @param pageSize
     * @return
     */
    @GetMapping("/{page}/{pageSize}")
    public R<Page<Goods>> pagingQueryGoods(@PathVariable("page") int page, @PathVariable("pageSize") int pageSize) {
        return goodsService.pagingQueryGoods(page, pageSize);
    }

    @GetMapping("/{gId}")
    public R<Goods> getGoodsInfo(@PathVariable("gId") String gId) {
        return goodsService.getGoodsInfo(gId);
    }
}
